package net.lab1024.sa.admin.module.business.yct.yctproductinstructions.controller;

import net.lab1024.sa.admin.module.business.yct.yctproductinstructions.domain.entity.YctProductInstructionsEntity;
import net.lab1024.sa.admin.module.business.yct.yctproductinstructions.domain.form.YctProductInstructionsAddForm;
import net.lab1024.sa.admin.module.business.yct.yctproductinstructions.domain.form.YctProductInstructionsQueryForm;
import net.lab1024.sa.admin.module.business.yct.yctproductinstructions.domain.form.YctProductInstructionsUpdateForm;
import net.lab1024.sa.admin.module.business.yct.yctproductinstructions.domain.vo.YctProductInstructionsVO;
import net.lab1024.sa.admin.module.business.yct.yctproductinstructions.service.YctProductInstructionsService;
import net.lab1024.sa.base.common.annoation.NoNeedLogin;
import net.lab1024.sa.base.common.domain.RequestUser;
import net.lab1024.sa.base.common.domain.ValidateList;
import net.lab1024.sa.base.common.util.SmartRequestUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 易齿通产品说明书 Controller
 *
 * @Author zhangben
 * @Date 2024-09-11 14:23:05
 * @Copyright yct
 */

@RestController
@Tag(name = "易齿通产品说明书")
public class YctProductInstructionsController {

    @Resource
    private YctProductInstructionsService yctProductInstructionsService;

    @Operation(summary = "分页查询 @author zhangben")
    @PostMapping("/yctProductInstructions/queryPage")
    @SaCheckPermission("yctProductInstructions:query")
    public ResponseDTO<PageResult<YctProductInstructionsVO>> queryPage(@RequestBody @Valid YctProductInstructionsQueryForm queryForm) {
        return ResponseDTO.ok(yctProductInstructionsService.queryPage(queryForm));
    }




    @Operation(summary = "添加 @author zhangben")
    @PostMapping("/yctProductInstructions/add")
    @SaCheckPermission("yctProductInstructions:add")
    public ResponseDTO<String> add(@RequestBody @Valid YctProductInstructionsAddForm addForm) {
        RequestUser requestUser = SmartRequestUtil.getRequestUser();
//        addForm.setCreateUserId(requestUser.getUserId());
//        addForm.setCreateUserName(requestUser.getUserName());
        return yctProductInstructionsService.add(addForm);
    }

    @Operation(summary = "更新 @author zhangben")
    @PostMapping("/yctProductInstructions/update")
    @SaCheckPermission("yctProductInstructions:update")
    public ResponseDTO<String> update(@RequestBody @Valid YctProductInstructionsUpdateForm updateForm) {
        return yctProductInstructionsService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author zhangben")
    @PostMapping("/yctProductInstructions/batchDelete")
    @SaCheckPermission("yctProductInstructions:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return yctProductInstructionsService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author zhangben")
    @GetMapping("/yctProductInstructions/delete/{instructionsId}")
    @SaCheckPermission("yctProductInstructions:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Long instructionsId) {
        return yctProductInstructionsService.delete(instructionsId);
    }
    @NoNeedLogin
    @PostMapping("/yctProductInstructions/queryPageList")
    public ResponseDTO<PageResult<YctProductInstructionsVO>> queryPageList(@RequestBody @Valid YctProductInstructionsQueryForm queryForm) {
        return ResponseDTO.ok(yctProductInstructionsService.queryPageList(queryForm));
    }

    @NoNeedLogin
    @GetMapping("/yctProductInstructions/select/{instructionsId}")
    public ResponseDTO<YctProductInstructionsVO> select(@PathVariable Long instructionsId) {
        return ResponseDTO.ok(yctProductInstructionsService.select(instructionsId));
    }
    @NoNeedLogin
    @GetMapping("/yctProductInstructions/selectTypeList")
    public ResponseDTO<List<YctProductInstructionsVO>> selectList() {
        return ResponseDTO.ok(yctProductInstructionsService.selectTypeList());
    }

}
